package com.neo.impatient.C04_MapTuple.C04_03_updateValue

object UpdateValue {


  def main(args: Array[String]): Unit = {

    val scores1 = scala.collection.mutable.Map("alice" -> 10, "bob" -> 3, "Cindy" -> 8)
    println(scores1)

    println("直接更新即可")
    scores1("bob") = 6
    println(scores1)

    println("新增一个元素")
    scores1("bob1") = 6

    println(scores1)
    println("新增一组元素")
    scores1 += ("hh" -> 9, "bb" -> 13)
    println(scores1)

    println("移除一个元素")
    scores1 -= "bob1"
    println(scores1)

    println("如果是对一个不可变Map新增 则可通过新建的方式")
    val scores2 = scores1 + ("ss"-> 78, "kk" -> 88)
    println(scores2)

    println("如果是对一个不可变Map移除 则可通过减的方式")
    val scores3 = scores2 - "bob"
    println(scores3)
  }

}
